<?php
if (isset($this->popupMessage)) {
    echo $this->popupMessage;
}

$categoryId = $this->formSelect('categoryId', null, array('size' => 10, 'class' => 'categoryId'), $this->category);
$Feature = $this->formSelect('FeatureId', null, array('class' => 'categoryId'), array('Chọn danh mục thuộc tính'));
$value = $this->form->value.'<span id="colorPicker"><img src="'.TEMPLATE_URL.'/admin/images/select_color.gif" width="25px" title="Chọn mã màu"><div id="colorpickerHolder2"></div></span>';

$arrInput = array(
    0 => array('label' => 'Tên thuộc tính: ', 'input' => $this->form->titleVi, 'requited' => 'YES'),
    //2 => array('label' => 'Giá trị: ', 'input' => $value, 'requited' => 'NO'),
    //3 => array('label' => 'Đơn giá: ', 'input' => $this->form->price, 'requited' => 'NO'),
    4 => array('label' => 'Thuộc danh mục: ', 'input' => $this->form->categoryId, 'requited' => 'YES'),
    //5 => array('label' => 'Danh mục thuộc tính: ', 'input' => '<div id="sl_Feature">'.$Feature.'</div>', 'requited' => 'YES'),
    6 => array('label' => 'Thứ tự hiển thị: ', 'input' => $this->form->weight, 'requited' => 'NO'),
    7=> array('label' => 'Hiển thị: ', 'input' => $this->form->status, 'requited' => 'NO'),
);

if (ENGLISH == 1) {
    $arrInput[1] = array('label' => 'Tên danh mục (Tiếng anh): ', 'input' => $this->form->titleEn, 'requited' => 'YES');
}

ksort($arrInput);
?>

<form role="form" id='frmCreateFeatureDetail' class='form-horizontal form-ajax-modal' novalidate="novalidate" onsubmit="return false;">
	<div class="modal-header">
		<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		<h4 class="modal-title">Thêm thuộc tính</h4>
	</div>
	<div class="modal-body">
	    <div class="row">
			<div class="col-md-12">
				<div class="panel panel-default">
					<div class="panel-body">
						<div class="row">
							<div class="col-md-12">
								<div id="alert-message"></div>							
					            <?php if (isset($this->error) && $this->error != '') { ?>
								<div class="errorHandler alert alert-danger">
									<button data-dismiss="alert" class="close" type="button">×</button>
									<i class="icon-remove-sign"></i> Thông báo
									<ul>
				                        <?php
					                        foreach ($this->error as $item) {
					                            echo '<li>' . $item . '</li>';
					                        }
				                        ?>
				                    </ul>
								</div>
								<?php } ?>
								
								<div class="successHandler alert alert-success no-display">
									<i class="icon-ok"></i> Your form validation is successful!
								</div>
							</div>
							<?php echo $this->form->featureId;?>
							<?php echo $this->partialLoop("_partials/row.phtml", $arrInput); ?>  											
						</div>					
						<div class="row">
							<div class="col-md-12">
								<div><hr></div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-9">
								<p>Các trường có dấu <span class="symbol required"></span> là bắt buộc</p>
							</div>
						</div>					
					</div>
				</div>
			</div>
		</div>
    </div>
	<div class="modal-footer">
		<button type="button" data-dismiss="modal" class="btn btn-light-grey">Close</button>
		<button type="submit" data-dismiss="modal" id='add-feature-detail' class="btn btn-blue ">Save changes</button>
	</div>
</form>	

<script>
    $(document).ready(function() {
    	Main.init();
    	standardURL('#titleVi', '#aliasVi');
    	standardURL('#titleEn', '#aliasEn');
    	
    	jQuery('.grey').parent().parent().parent().attr('style','display: inline-flex');
    	
        $('#parentId').change(function() {
            var level = $(this + 'option:selected').attr('data-level');
            if ($(this)[0].selectedIndex === 0) {
                level = 0;
            }

            $('#level').val(parseInt(level) + 1);
        });

        $('.alert .close').live('click', function() {
            $(this).parents('#alert-message').fadeOut();
            $(this).parent('.alert').fadeOut();
        });

        $('#titleVi, #titleEn').keyup(function() {
            var value = $(this).val();
            if (value != '') {
                $(this).removeClass('required-error');
            }
        });



    });

    
</script>